import {Pipe, PipeTransform} from '@angular/core';

@Pipe({
  name: 'formatTime'
})
export class FormatTimePipe implements PipeTransform {

  transform(time: number): string {
    if (!time) {
      return '00:00';
    }

    const oldTime = Math.floor(time);
    const minutes = Math.floor(oldTime / 60);
    const seconds = (oldTime % 60).toString().padStart(2, '0');
    return `${minutes}:${seconds}`;
  }

}
